﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using MySql.Data.MySqlClient;


namespace LKS
{
    public partial class halaman_1 : Form
    {
        private int _failedLoginCounter = 0;
        string MyConnectionString = "Server=localhost;Database=testdb;Uid=root;Pwd=password";
        public halaman_1()
        {
            InitializeComponent();
        }

        private void login_UserBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.login_UserBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.dBLKSDataSet);

        }

        private void login_UserBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
        {
            this.Validate();
            this.login_UserBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.dBLKSDataSet);

        }

        private void halaman_1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dBLKSDataSet.Login_User' table. You can move, or remove it, as needed.
            this.login_UserTableAdapter.Fill(this.dBLKSDataSet.Login_User);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string strSQL = "Select * From mdl_user where username = @txtUsername AND password=@txtPassword";
            MySqlConnection connection = new MySqlConnection(MyConnectionString);
            connection.Open();

            try {
                MySqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = strSQL;
                
                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Console.WriteLine(reader["username"].ToString());
                    }
                }

            }
    
            
        }
    }
}
